import 'package:flutter/material.dart';

class Tabs extends StatefulWidget {
  final TabController tabc;

  final List tabs;

  const Tabs({Key key, this.tabc, this.tabs}) : super(key: key);
  @override
  _TabsState createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  int tabIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          height: 50,
          child: TabBar(
            controller: widget.tabc,
            onTap: (val) {
              setState(() {
                tabIndex = val;
              });
            },
            tabs: widget.tabs
                .map((item) => Tab(
                      text: item['name'],
                    ))
                .toList(),
            //  indicatorPadding: EdgeInsets.only(bottom: 1),
            labelColor: Color.fromRGBO(191, 55, 54, 1),
            unselectedLabelColor: Colors.black,
            indicatorColor: Color.fromRGBO(191, 55, 54, 1),
            indicatorSize: TabBarIndicatorSize.label,
            indicatorWeight: 3,
          ),
        ),
        Container(
          padding: EdgeInsets.symmetric(horizontal: 12),
          height: 450,
          child: TabBarView(
              controller: widget.tabc,
              children: widget.tabs
                  .map((items) => Container(child: Text('$items')))
                  .toList()),
        ),
      ],
    );
  }
}
